<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>login</title>
</head>
<body>
<div id = "app">
        <input type="text" name="username" v-model="username"><br>
        <input type="text" name="password" v-model="password"><br>
        <button @click="login()">登录</button>
    <button @click="myinfo()">myinfo</button>
</div>
<script src="http://47.106.66.89:8080/js/vue.min.js"></script>
<script src="http://47.106.66.89:8080/js/axios.min.js"></script>
<link href="http://47.106.66.89:8080/js/ele-2.15.7/theme-chalk/index.css" rel="stylesheet">
<script src="http://47.106.66.89:8080/js/ele-2.15.7/index.js"></script>
<script>
    var v = new Vue({
        el : "#app",
        data : {
            username:'',
            password:''
        },
        created() {
            this.myinfo()
        },
        methods : {
            myinfo(){
                var jwt = sessionStorage.getItem("jwt");
                axios.get("damai-user/sign/myinfo",{
                    headers:{
                        Authorization: jwt
                    }
                }).then(res=>{
                    console.info(res.data);
                    this.$alert(res.data.msg);
                })
            },
            login(){
                axios.get(`user/sign/login?username=${this.username}&password=${this.password}`).then(res=>{
                    console.info(res.headers.authorization);
                    sessionStorage.setItem("jwt", res.headers.authorization);
                    if(res.data.code == 1){
                        this.$alert(res.data.msg);
                    }else{
                        this.$message(res.data.msg);
                    }
                });
            }
        }
    })
</script>
</body>
</html>